<?php
class IndexController extends Zendvn_Controller_Action{
	
	public function init(){
		parent::init();		
		$this->_templateObj->setPath(TEMPLATE_PATH . '/public/default');		
		$this->_templateObj->load();	
		
		
		$this->view->arrParam = $this->_arrParam;
	}
	
	public function indexAction(){
		$tblProductCategory = new Zendvn_Model_Table_ProductCategories();
		$this->view->Items = $tblProductCategory->itemInSelect($this->_arrParam, array('task' => 'cat-index'));
	}
	
	public function newsAction(){
		$tblNews = new Zendvn_Model_Table_NewsItem();
		$this->view->tblNews = $tblNews;
		$this->view->Items = $tblNews->listItem($this->_arrParam, array('task' => 'list-news'));
	}
	
	public function newsDetailAction(){
		$tblNews = new Zendvn_Model_Table_NewsItem();
		$this->view->Item = $tblNews->getItem($this->_arrParam);
	}

	public function registerAction(){
		if($this->_request->isPost()){
			$validator = new User_Form_ValidateReview($this->_arrParam);
			if($validator->isVaild()){
				$arrError = $validator->getMessageErrors();
				$response = array('type' => 'error','msg'=>$arrError);
			}else{
				$data =  $validator->getData();
				
				$response = array('type' => 'success');
			}
			echo json_encode($response);
			$this->_helper->layout()->disableLayout();
			$this->_helper->viewRenderer->setNoRender();
		}
	}

}